exports.objectToUrlParam = objectToUrlParam;
exports.getNowPageParam = getNowPageParam;

// 获取当前页面url参数
function getNowPageParam() {
  var url = document.location.href.split('?')[1];
  var param = {};

  if (url) {
    url = url.replace(/#\//g, '');
    var strs = url.split('&');

    for (var i = 0; i < strs.length; i++) {
      param[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]);
    }
  }

  return param;
}

// obj转url参数
function objectToUrlParam(object) {
  var urlParam = '';
  var urlParamArray = [];

  for (var key in object) {
    urlParamArray.push(key + '=' + object[key]);
  }

  urlParam = urlParamArray.join('&');
  return urlParam;
}